import asyncio

from fastmcp import Client


async def run_client():
    """
    运行客户端
    :return:
    """
    async with Client("http://localhost:8090/sse") as client:
        tools = await client.list_tools()
        print(f"可用的工具列表: {tools}")

        resources = await client.list_resources()
        print(f"可用的资源列表: {resources}")

        get_stock_info_result = await client.call_tool("get_stock_info", {"code": "00700"})
        print(f"调用工具 get_stock_info 返回的结果 : {get_stock_info_result}")

        app_version_result = await client.read_resource("config://app-version")
        print(f"读取资源 config://app-version 返回的结果 : {app_version_result}")

        stock_codes_result = await client.read_resource("data://stock-codes")
        print(f"读取资源 data://stock-codes 返回的结果 : {stock_codes_result}")

        introduce_stock_result = await client.get_prompt("introduce_stock", {"code": "00700"})
        print(f"获取提示 introduce_stock 返回的结果 : {introduce_stock_result}")


if __name__ == "__main__":
    asyncio.run(run_client())
